🐛 FIX: Double encoded ampersands in query params#929
Open
sumezulike wants to merge 1 commit intoexecutablebooks:masterfrom
Open
🐛 FIX: Double encoded ampersands in query params#929sumezulike wants to merge 1 commit intoexecutablebooks:masterfrom
sumezulike wants to merge 1 commit intoexecutablebooks:masterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #929 +/- ##
==========================================
+ Coverage 90.13% 90.15% +0.02%
==========================================
Files 24 24
Lines 3416 3423 +7
==========================================
+ Hits 3079 3086 +7
Misses 337 337
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
chrisjsewell
requested changes
May 12, 2024
Comment on lines
+272
to
+275
| HTMLTranslator.special_chars_no_amp = { # needed by encode_fixed | ||
| k: v for k, v in HTMLTranslator.special_characters.items() if k != ord("&") | ||
| } | ||
| HTMLTranslator.encode = encode_fixed |
Member
There was a problem hiding this comment.
I'm afraid this is not something that cannot be merged; it would break restructuredtext parsing.
Monkey patching is done strictly as a last resort, and only for where the patch does not affect upstream use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This closes #760.
MyST already escapes the
&in the query params, but docutils escapes them again when rendering HTML, leading to broken query params.becomes
instead of
These changes to the docutils parser override the
HTMLTranslator.encodefunction so already encoded ampersands are not encoded again.Since the issue lies in the interaction with docutils, I think it makes sense to fix it here.
Also, simply removing the
escapeHtmlcall in MyST makes the sphinx app doctree XML files invalid because the ampersands aren't escaped.